package org.zxw.controller.trainPlan;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.zxw.service.AiTrainingPlanService;

import java.util.HashMap;
import java.util.Map;


//配置消息未完善，未测试
@RestController
@RequestMapping("/api/v1/ai-plan/")
public class AiTrainingPlanController {
    private final AiTrainingPlanService aiPlanService;
    
    public AiTrainingPlanController(AiTrainingPlanService aiPlanService) {
        this.aiPlanService = aiPlanService;
    }
    
    @PostMapping("/generate")
    public ResponseEntity<String> generatePlan(
            @RequestParam String description,
            @RequestParam(defaultValue = "初级") String level) {
        try {
            String plan = aiPlanService.generateTrainingPlan(description, level);
            return ResponseEntity.ok(plan);
        } catch (Exception e) {
            return ResponseEntity.status(HttpStatus.TOO_MANY_REQUESTS)
                .body(e.getMessage());
        }
    }
    
    @GetMapping("/example")
    public ResponseEntity<Map<String, String>> getExamplePrompt() {
        Map<String, String> example = new HashMap<>();
        example.put("description", "我想增肌但时间有限，每周只能锻炼3次，每次不超过45分钟");
        example.put("level", "中级");
        example.put("提示", "您可以使用以上示例格式提交请求");
        return ResponseEntity.ok(example);
    }
}